package com.migration.model.migration.scripts;

import com.migration.model.migration.AbstractMigrationScript;

/**
 * 风险区域设备关联表(risk_area_device)迁移脚本
 */
public class A002_RiskAreaDeviceMigrationScript extends AbstractMigrationScript {

    /**
     * 构造函数，初始化迁移配置
     */
    public A002_RiskAreaDeviceMigrationScript() {
        super(
            "risk_area_device",
            "风险区域设备关联数据迁移",
            "ra_area_linked",
            "risk_area_device",
            2
        );
    }

    /**
     * 生成迁移数据的SQL
     *
     * @return 迁移数据的SQL
     */
    @Override
    protected String generateMigrationSql() {
        return "INSERT INTO risk_area_device (id, area_id, device_id)\n" +
               "SELECT id, area_id, linked_id\n" +
               "FROM risk_lunnan_test.ra_area_linked\n" +
               "WHERE linked_type = 3;";
    }

    /**
     * 获取源数据SQL
     *
     * @return 源数据查询SQL
     */
    public String getSourceSql() {
        return "SELECT id, area_id, linked_id\n" +
               "FROM risk_lunnan_test.ra_area_linked\n" +
               "WHERE linked_type = 3;";
    }

    /**
     * 获取目标数据SQL模板
     *
     * @return 目标数据SQL模板
     */
    public String getTargetSqlTemplate() {
        return "INSERT INTO risk_area_device (id, area_id, device_id)";
    }
}
